package com.hs.android.fortress.model;

import com.google.android.gms.maps.model.LatLng;


public class Player {
    
    public static final int NORMAL_STATE = 0;
    public static final int WAIT_ROOM_STATE = 1;
    public static final int PLAY_GAME_STATE = 2;
    
    private String id;
    private int roomId;
    private int state;
    private double latitude;
    private double longitude;
    private Tank tank;
    private int energy;
    private int win;
    private int lose;
    private int draw;

    public Player(){
    }

    public Player(String id, int win, int lose, int draw) {
        this.id = id;
        this.win = win;
        this.lose = lose;
        this.draw = draw;
    }
    
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public int getRoomId() {
        return roomId;
    }

    public void setRoomId(int roomId) {
        this.roomId = roomId;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public double getLatitude() {
        return latitude;
    }

    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }

    public double getLongitude() {
        return longitude;
    }

    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

    public Tank getTank() {
        return tank;
    }

    public void setTank(Tank tank) {
        this.tank = tank;
    }

    public int getEnergy() {
        return energy;
    }

    public void setEnergy(int energy) {
        this.energy = energy;
    }

    public int getWin() {
        return win;
    }

    public void setWin(int win) {
        this.win = win;
    }

    public int getLose() {
        return lose;
    }

    public void setLose(int lose) {
        this.lose = lose;
    }

    public int getDraw() {
        return draw;
    }

    public void setDraw(int draw) {
        this.draw = draw;
    }
    
    public LatLng getPosition(){
    	return new LatLng(latitude, longitude);
    }
    
    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Player)) {
            return false;
        }
        Player other = (Player) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }
    
    public double calculateWinRate(){
    	
    	if(win == 0)
    		return 0.0;
    	
		return 100*((double)win/(win+lose));
	}
}